package jers.example;

import java.io.Serializable;
import java.rmi.RemoteException;

import jers.Callback;
import jers.JERS;
import jers.Job;
import jers.Service;

public class HelloWorld implements Runnable, Serializable {

	private static final long serialVersionUID = -8442516604905381814L;
	
	public void run() {
		System.out.println("\n>> Ola mundo! <<\n");
	}

	public static void main(String[] args) throws Exception {
		
		String server = "localhost";
		
		try {
			HelloWorld hello = new HelloWorld();
			Job job = JERS.factory.newJob(hello);
			Callback callback = JERS.factory.newCallback(hello); 
			
			Service service = JERS.getService(server);
			
			// Synchronous Call
			service.execute(job);
			
			// Asynchronous Call
			service.dispatch(job, callback);
			
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	
}


